//
//  SamNavigationController.m
//  AoJiao
//
//  Created by Sam on 16/8/13.
//  Copyright © 2016年 Shawn. All rights reserved.
//

#import "SamNavigationController.h"

@interface SamNavigationController ()

@end

@implementation SamNavigationController

#pragma mark - ----------------------
#pragma mark - 设置title文字和背景图片


+ (void)initialize
{
    // 设置全局导航条
    UINavigationBar *bar = [UINavigationBar appearance];
    
    [bar setTintColor:samColor];
    bar.translucent = YES;
    // 设置当类的全局导航条标题字体
    NSMutableDictionary *attri = [NSMutableDictionary dictionary];
    attri[NSFontAttributeName] = [UIFont boldSystemFontOfSize:18];
    [bar setTitleTextAttributes:attri];
    
    UIBarButtonItem *item = [UIBarButtonItem appearance];
    NSMutableDictionary *normalAttri = [NSMutableDictionary dictionary];
    //Sam修改
    normalAttri[NSForegroundColorAttributeName] = samColor;
    //normalAttri[NSForegroundColorAttributeName] = [UIColor colorWithHexString:@"0x191919"];
    normalAttri[NSFontAttributeName] = [UIFont systemFontOfSize:15];
    [item setTitleTextAttributes:normalAttri forState:UIControlStateNormal];
    
    NSMutableDictionary *disabledAttri = [NSMutableDictionary dictionary];
    disabledAttri[NSForegroundColorAttributeName] = [UIColor lightGrayColor];
    [item setTitleTextAttributes:disabledAttri forState:UIControlStateDisabled];
    
    //背景图片
    [bar setBackgroundImage:[UIImage imageNamed:@"navigationbarBackgroundWhite"] forBarMetrics:UIBarMetricsDefault];
    
}


- (void)viewDidLoad {
    [super viewDidLoad];
//    self.navigationBar.tintcolor = [UIColor orangecolor];
//    [self.navigationBar setBackgroundColor:[UIColor colorWithHexString:@"faf209" alpha:1]];
//    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, -20, SamScreenW, 64)];
//    view.backgroundColor = [UIColor colorWithHexString:@"faf209" alpha:1];
//    [self.navigationBar addSubview:view];
    

    
    // Do any additional setup after loading the view.
}

#pragma mark - ----------------------
#pragma mark - push
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    
    if (self.childViewControllers.count > 0) {
//        //button
//        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
//        [btn setTitle:@"返回" forState:UIControlStateNormal];
//        [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
//        [btn setTitleColor:[UIColor redColor ] forState:UIControlStateHighlighted];
//        [btn setImage:[UIImage imageNamed:@"navigationButtonReturn"] forState:UIControlStateNormal];
//        [btn setImage:[UIImage imageNamed:@"navigationButtonReturnClick"] forState:UIControlStateHighlighted];
//        //size
//        [btn sizeToFit];
//        btn.contentEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0);
//        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:btn];
//        //add target
//        [btn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
//
//        viewController.navigationItem.leftBarButtonItem set
        //隐藏tabbar
        viewController.hidesBottomBarWhenPushed = YES;
        
        
    }
    //****真正跳转
    [super pushViewController:viewController animated:animated];
    
}

//- (void)back {
//    
//    [self popViewControllerAnimated:YES];
//}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
